﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yc.Dal;

namespace yc.Site.Controllers
{
	public class CompanyAuditControll : Controller
	{
		public ActionResult Index(FormCollection c)
		{
			var Contact = c.Get("Contact");
			var Telephone = c.Get("Telephone");
			var db = new DBContext();

			IQueryable<SysCompany> query = db.SysCompany;

			if (!string.IsNullOrEmpty(Contact)) query = query.Where( p => p.SysCompanyContact.Any(q => q.Contact.Contains(Contact)));
			if (!string.IsNullOrEmpty(Telephone)) query = query.Where(p => p.SysCompanyContact.Any(q => q.Telephone.Contains(Telephone)));

			var pager = query.ToPager("CreateDate");
			return View(pager);
		}
	}
}